package com.pinxi.service;

import com.pinxi.mapper.UserMapper;
import com.pinxi.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import sun.security.provider.MD5;

import java.util.List;
import java.util.UUID;

/**
 * @Author shaohe_zhang
 * @Date 2022/1/24 14:53
 * @Version 1.0.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getAll() {
        return userMapper.getAll();
    }

    @Override
    public String login(User user) {
        user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
        User user1 = userMapper.findUserByUP(user);
        if (user1 == null)
            return null;
        String uuid = UUID.randomUUID().toString().replace("-", "");
        return uuid;
    }
}
